//! \file linux_arm_exidx_elf.h

#include "linux_elf_utils.h"

//------------------------------------------------------------------------------

#ifndef _LINUX_ARM_EXIDX_ELF_H_
#define _LINUX_ARM_EXIDX_ELF_H_

//------------------------------------------------------------------------------

#define MAX_CMD_BUF_LENGTH 32
#define ARM_FINISH_CMD_CODE 0xB0

//------------------------------------------------------------------------------

typedef struct {
    addr_t exidx;
    size_t exidx_len;
} elf_unwind_session;

//------------------------------------------------------------------------------

// works only with local, not library functions.
TBGError InitUnwindSession(elf_unwind_session *pelf); 

// TODO: how to be with ptrace?!:(
TBGError ElfFindUnwindInfo(elf_unwind_session *pelf, addr_t addr);

TBGError ElfGetUnwindCmd(elf_unwind_session *pelf, addr_t addr,
                         uint8_t *cmd_buf, size_t *pbuf_len);

TBGError ExidxBinarySearch(elf_unwind_session *pelf, addr_t search,
                           addr_t *pret); 

//------------------------------------------------------------------------------

#endif //_LINUX_ARM_EXIDX_ELF_H_
